function myAjax(method,url,data){
    let p = new Promise((resolve,reject)=>{
        data = data||'';
        let ajax = new XMLHttpRequest();
        ajax.open(method,url);
        ajax.setRequestHeader('Content-type','application/json');

        ajax.onreadystatechange = function(){
            if(ajax.readyState === 4 && ajax.status === 200){
                resolve(ajax.responseText);
            }
        }
        ajax.onerror = function(e){
            reject(e);
        }
        ajax.send(JSON.stringify(data));
    })
    return p;
}
